﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using UI.Model;
using System.Windows.Controls;
using UI.Views;

namespace UI.Presenters
{
    public class ApplicationPresenter : PresenterBase<MainWindow>
    {
        private readonly FilterRepository _filterRepository;
        //private ObservableCollection<Contact> _currentContacts;
        private string _statusText;
        public ApplicationPresenter(
            MainWindow view,
            FilterRepository filterRepository)
        : base(view)
        {
            _filterRepository = filterRepository;
        }
/*public ObservableCollection<Contact> CurrentContacts
{
get { return _currentContacts; }
set
{
_currentContacts = value;
OnPropertyChanged(“CurrentContacts”);
}
}*/
        public string StatusText
        {
            get { return _statusText; }
            set
            {
                _statusText = value;
                OnPropertyChanged("StatusText");
            }
        }
        public void Search(string criteria)
        {
            StatusText = "Displaying all filters";
        }
        public void CloseTab<T>(PresenterBase<T> presenter)
        {
            View.RemoveTab(presenter);
        }
        public void UpdateSimCharts(RichTextBox filtDef)
        {
            _filterRepository.Parse(filtDef);
            View.RemoveTab(this);
            for (int i = 0; i < _filterRepository.SequenceCount; i += 1)
                View.AddTab(
                    new SimulationPresenter(
                        this,
                        new SimulationView(_filterRepository.FilterResponse(i))
                ));
            
            /*View.AddTab(
                new SimulationPresenter(
                    this,
                    new SimulationView(new KeyValuePair<string, int>[] {
                new KeyValuePair<string, int>("Silverlight", 1), 
                new KeyValuePair<string, int>(".NET 3.5", 2), 
                new KeyValuePair<string, int>("ASP", 3), 
                new KeyValuePair<string, int>("AJAX", 4), 
                new KeyValuePair<string, int>("VC++", 5),
                new KeyValuePair<string, int>("C#", 6),
                new KeyValuePair<string, int>("SQL Server", 7) 
            }))
            );*/
        }
    }
}
